package com.atguigu02.singleton;

/**
 * @author NoobMaster69  * @date 2024/5/31 0031 星期五 15:23
 */
public class BankTest {
    public static void main(String[] args) {
        Bank bank1 = Bank.setInstance();
    }
}
//饿汉式
class Bank{
    //1.将类的构造器私有化
    private Bank(){}
    //2.在类的内部创建当前的实例
    //4.此属性也必须修饰static
    private static Bank instance = new Bank();
    //3.通过setXx方法返回
    public static Bank setInstance(){
        return instance;
    }
}
